import Http from "@/http"
import { dictionaryItemByCategoryApi } from "./system/Dictionary"


export function pageApi(params:any) {
    return Http.post('chargingStation/page', params)
}

export function saveApi(params:any) {
    return params.id ? Http.put('chargingStation/update/' + params.id, params) : Http.post('chargingStation/add', params)
}

export function deleteApi(id) {
    return Http.delete('chargingStation/delete/' + id)
}


export function uploadPicApi(pic:File) {
    const formData = new FormData()
    formData.append('pic', pic)
    return Http.post('chargingStation/upload/pic', formData)
}


export function bindDevicesApi(stationId:number, deviceIds:number[]) {
    return Http.post('device/bind/station', {ids:deviceIds, id:stationId})
}

export function unbindDevicesApi(deviceIds:number[]) {
    return Http.post('device/unbind/station', {ids:deviceIds})
}

export function getLabelsApi() {
    return dictionaryItemByCategoryApi('CHARGE_STATION_LABEL')
}

export function pushSettingApi(ids:number[]) {
    return Http.post('chargingStation/push/setting', {ids:ids})
}

export function infoApi(id) {
    return Http.get('chargingStation/info/' + id)
}